<?php

$showurl = @file_get_contents('http://epguides.com/'.$getshow.'/');

if ($showurl) {

	//Get epguides.com Title
	preg_match('#<title>.+\(#iU', $showurl, $title);
	$showname =  trim(substr($title[0], 7, -2),  " :\n\t\r!");

	//Parse and split up epguides content
	$subject = $showurl;


	$pattern = '#([0-9]{1,3}\.)(\s+)('.$season_name.'\-[\s]?[0-9 ]{1,2})(\s+)([0-9a-zA-Z\s-]+)(\s+)([0-9]{1,2}[\s]?[a-zA-Z]{3}[\s]?[0-9]{2})(\s+)(<a target="(_blank|visit)" href="http://www.tv.com[\D\d\s]+>)([\D\d\s]+</a>)#iU';


	preg_match_all($pattern, $subject, $matches);

   	$numbers = $matches[1];
   	$episodes = $matches[3];
   	$urls = $matches[9];
   	$titles = $matches[11];
   	$arrayShows = array();

   	for( $x = 0; $x < count($numbers); $x++ ){
         $number = array('number' => $numbers[$x], 'episode' => $episodes[$x], 'url' => $urls[$x], 'title' => $titles[$x]);
         array_push($arrayShows, $number);
    }
}
?>